package com.tjec.project.businessStandardLibrary.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.businessStandardLibrary.domain.BmsKnowledgePolicies;
import com.tjec.project.businessStandardLibrary.service.IBmsKnowledgePoliciesService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 法规导航Controller
 * 
 * @author pangyongfeng
 * @date 2020-04-21
 */
@Api("法规导航")
@RestController
@RequestMapping("/library/policies")
public class BmsKnowledgePoliciesController extends BaseController
{
    @Autowired
    private IBmsKnowledgePoliciesService bmsKnowledgePoliciesService;

    /**
     * 查询法规导航列表
     */
    @ApiOperation("查询法规导航列表")
    @PreAuthorize("@ss.hasPermi('library:policies:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsKnowledgePolicies bmsKnowledgePolicies)
    {
        startPage();
        List<BmsKnowledgePolicies> list = bmsKnowledgePoliciesService.selectBmsKnowledgePoliciesList(bmsKnowledgePolicies);
        return getDataTable(list);
    }

    /**
     * 导出法规导航列表
     */
    @ApiOperation("导出法规导航列表")
    @PreAuthorize("@ss.hasPermi('library:policies:export')")
    @Log(title = "法规导航", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmsKnowledgePolicies bmsKnowledgePolicies)
    {
        List<BmsKnowledgePolicies> list = bmsKnowledgePoliciesService.selectBmsKnowledgePoliciesList(bmsKnowledgePolicies);
        ExcelUtil<BmsKnowledgePolicies> util = new ExcelUtil<BmsKnowledgePolicies>(BmsKnowledgePolicies.class);
        return util.exportExcel(list, "policies");
    }

    /**
     * 获取法规导航详细信息
     */
    @ApiOperation("获取法规导航详细信息")
    @PreAuthorize("@ss.hasPermi('library:policies:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(bmsKnowledgePoliciesService.selectBmsKnowledgePoliciesByGuid(guid));
    }

    /**
     * 获取法规导航详细信息
     */
    @ApiOperation("获取法规导航详细信息")
    @PreAuthorize("@ss.hasPermi('library:policies:query')")
    @GetMapping(value = "/details")
    public AjaxResult details( String guid)
    {
        return AjaxResult.success(bmsKnowledgePoliciesService.selectBmsKnowledgePoliciesByGuid(guid));
    }


    /**
     * 新增法规导航
     */
    @ApiOperation("新增法规导航")
    @PreAuthorize("@ss.hasPermi('library:policies:add')")
    @Log(title = "法规导航", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsKnowledgePolicies bmsKnowledgePolicies)
    {
        return toAjax(bmsKnowledgePoliciesService.insertBmsKnowledgePolicies(bmsKnowledgePolicies));
    }

    /**
     * 修改法规导航
     */
    @ApiOperation("修改法规导航")
    @PreAuthorize("@ss.hasPermi('library:policies:edit')")
    @Log(title = "法规导航", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsKnowledgePolicies bmsKnowledgePolicies)
    {
        return toAjax(bmsKnowledgePoliciesService.updateBmsKnowledgePolicies(bmsKnowledgePolicies));
    }

    /**
     * 删除法规导航
     */
    @ApiOperation("删除法规导航")
    @PreAuthorize("@ss.hasPermi('library:policies:remove')")
    @Log(title = "法规导航", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(bmsKnowledgePoliciesService.deleteBmsKnowledgePoliciesByGuids(guids));
    }
}
